
(defun mappend (fn &rest lsts)
  "maps elements in list and finally appends all resulted lists."
  (apply #'append (apply #'mapcar fn lsts)))

(defun cross-product (fn xlist ylist)
  "Return a list of all (fn x y) values."
  (MAPPEND (lambda (y)
             (mapcar (lambda (x)
                       (funcall fn x y))
                     xlist))
           ylist))


;;; TESTING
(format t "~a~%" (cross-product #'+ '(1 2 3) '(10 20 30)))
(format t "~a~%" (cross-product #'list '(a b c d e) '(1 2 3 4 5)))
